package com.example.singletones;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.example.R;

public class NotificationCaller {

	private static final int MY_NOTIFICATION_ID = 1;
	private NotificationManager notificationManager;
	private static NotificationCaller instance = null;
	private Notification myNotification;

	protected NotificationCaller() {

	}

	public static NotificationCaller getInstance() {
		if (instance == null) {
			instance = new NotificationCaller();
		}
		return instance;
	}

	public void MakeNotif(String title, String Text) {
		notificationManager = (NotificationManager) contextObj.getInstance()
				.getmContext().getSystemService(Context.NOTIFICATION_SERVICE);
		myNotification = new Notification(R.drawable.icon, "Notification!",
				System.currentTimeMillis());
		notificationManager.cancel(MY_NOTIFICATION_ID);
		Context context = contextObj.getInstance().getmContext()
				.getApplicationContext();
		String notificationTitle = title;
		String notificationText = Text;
		Intent myIntent = new Intent(Intent.ACTION_VIEW);
		PendingIntent pendingIntent = PendingIntent.getActivity(contextObj
				.getInstance().getmContext(), MY_NOTIFICATION_ID, myIntent,
				Intent.FLAG_ACTIVITY_NEW_TASK);
		myNotification.defaults |= Notification.DEFAULT_SOUND;
		myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
		myNotification.setLatestEventInfo(context, notificationTitle,
				notificationText, pendingIntent);
		notificationManager.notify(MY_NOTIFICATION_ID, myNotification);

	}
}
